|
This document describes how to compress video effectively using Indeo video 5. Read it if you plan to use Indeo video 5 to produce multimedia applications for CD-ROM, or videos to be distributed from a Web site.
NOTE: This paper assumes that you have installed the latest Indeo video drivers, software for video capture and editing (such as Adobe Premiere* or Asymetrix Digital video Producer*), and a supported video playback environment (such as Microsoft's video for Windows* or ActiveMovie*).
This document is divided into the following sections:
Choosing compression settings in your video-editing application
This section discusses choosing the following settings:
Choosing settings in the Indeo Video 5 compression dialog box
This section describes how to choose compression settings specific to Indeo video 5 including:
Using transparency without application support
You can read about workarounds for incorporating transparency into your video even if you are using an editing application that does not support this feature directly.
Conclusion
This section summarizes the key points.
These are the steps for choosing compression setting. Each step is discussed in detail below.
Another control called the Quality slider (typically expressed as a percentage) is usually present, as well. If you enter a nonzero value into the Data Rate box, the Quality slider is ignored. Setting the Data Rate instead of the Quality control results in compressed video files with a nearly constant average data rate from beginning to end, but with varying quality, as the video content becomes easier or harder to compress. Using this setting is appropriate any time you want a specific data rate or file size, as you would for playing from a CD-ROM or streaming over a network of a certain speed.
To use the Data Rate control, select the box and enter a target data rate, expressed in kilobytes-per-second. The encoder attempts to output compressed data at an average data rate as close to the target value as possible. It usually isn't exact, because video files typically vary in compressibility from beginning to end, and the encoder must change quality as needed.
If you do not select the Data Rate, or if you enter a value of zero, the Quality slider is enabled. The higher you set it, the higher the overall data rate and the better the visual quality of the resulting file. Using the Quality slider results in a video file of constant quality from beginning to end. However, with variable data rates, the video content becomes easier or harder to compress. Another benefit of using the Quality slider is speed. The Indeo video 5 encoder runs approximately twice as fast when using the Quality slider. Use this setting any time strict control of the average data rate is not as important (for downloaded video, or other video played from a hard disk). Also use it when you don’t want to vary the quality of a video during playback (to maintain a fixed data rate).
You can obtain a file of approximately the size you want using the Quality slider. It just requires a bit of trial and error. Obtaining a file with the quality level you want is much simpler using the Quality slider. To use the quality slider, position the control at the quality percentage you want (100% is maximum quality, and 0% is minimum quality).
The file size or data rate required to compress a video to some acceptable level of quality varies depending on the content. For example, computer-generated animation sequences consisting of simple backgrounds, low detail, and little motion, usually compress extremely well. However, some video sequences like live sporting events featuring complex backgrounds and lots of motion, require a much higher data rate. The audio data also requires space in the file. This is particularly important to remember when using the Data Rate control, because the required data rate for audio is subtracted directly from the value you enter into the box. Because uncompressed high-quality audio can be quite large (even compared to compressed video), consider using compressed audio when a low data rate is particularly important.
Compressed audio presents a different situation. If you are using compressed audio, the size of the audio chunks will probably be much smaller. So the issues described above are less important. Furthermore, many audio-compression formats do not perform well with audio interleaving set to one frame. This is because these formats require larger chunks of audio to be grouped together in order to obtain good compression. If the audio is then interleaved 1:1, the audio decoder may not have the entire chunk of compressed audio it requires at any given time to play correctly. So you should always interleave compressed audio at a higher rate, like every 1/2 second (the number of frames depends on the video frame rate), or as recommended by your audio codec documentation.
Most video capture applications do not interleave audio and video during capture, so the frames are interleaved at an interval much higher than 1:1. If this is the case, even if you do not wish to recompress the video, you must interleave the audio if you want to put the file on a CD-ROM. Interleave any existing file as follows:
To maximize image quality while still maintaining low data rates, Indeo video 5 uses a combination of intraframe and interframe encoding. Key frames are encoded only with respect to themselves; they are essentially still images (similar to JPEG), containing all of the visual information needed to display them. This is intraframe encoding. Delta frames do not contain all of the visual information necessary to display them. Instead, they contain only information representing differences from other frames. This is interframe encoding. Both types of frames are useful, and both have limitations:
The first frame of every video file must be a key frame. After the first frame, the codec places key frames periodically between groups of delta frames to enable random access (seeking) within the file. The key frame interval controls the frequency with which key frames occur. (Indeo video version 5 version also allows developers to place key frames explicitly; for example, at scene changes, or wherever random user access is required.)
An example file using the Indeo video 5 default key frame interval of 15 appears as shown in Figure 1. (Key frames are labeled with a K; delta frames with a D.)
Figure 1. Key Frames and Delta Frames in the Video File
In addition to affecting data rate and random access, the key frame interval also affects playback performance. When you play a video on a system with a slow CPU or CD-ROM drive, the video decode and display can lag behind the audio playback. When this occurs, Video for Windows* tries to speed up the video either by decoding some video frames but not displaying them, or by not decoding them at all. If a frame is neither decoded nor displayed, it is dropped.
The effect of dropping a frame depends on:
If a key frame is dropped, every subsequent delta frame is dropped until the next key frame. Files with higher key frame intervals drop more frames. If a delta frame is dropped, the effect varies. Some types of delta frames can be dropped without affecting the decode of any subsequent delta frames. However, other types of delta frames contain information needed by following frames. If one of these delta frames is dropped, some number of frames that follow will be dropped as well. How many frames depends on the type of delta frame dropped and the key frame interval. A key frame interval of one second (equal to the frame rate) usually yields good results for CD-ROM applications.
When authoring for Progressive Download (or any video download application), a key frame interval of 1 to 3 seconds is usually best, as a trade-off between good compression, random access, and playback performance. To ensure that progressively downloaded video plays back smoothly during the lower framerate phases of the download, choose key frame intervals that meet the following criteria:
If these guidelines are not followed, when the video is played during an early download phase at a reduced frame rate (e.g. 5 fps), the key frames may not be spaced evenly with respect to the other frames downloaded to this point, causing the playback to temporarily look jumpy until more levels of the download have arrived. Also note that the key frame interval selected for compressions authored for Progressive Download has an effect on the lowest frame rate (and data rate) achievable in the first download phase. For example, a video clip compressed with a key frame interval of 1 (all key frames) will have a relatively high datarate overall, and will not be able to transmit a lower frame rate in early phases of the progressive download. For network streaming applications, a very high key frame interval (at least 3 to 5 seconds worth of frames) is typically best, to minimize data rate. In this case, key frames are only necessary to provide a re-synchronization point if frames are dropped, since random access is not possible in a streaming file.
When setting a very low key frame interval (less than five), and using the Data Rate control to target a relatively low data rate, you may notice that the compressor does not achieve the requested data rate. This is normal, and means that the data rate requested is too low for the requested key frame interval. This occurs because the encoder gives key frames priority over data rate control. Ordinarily, the encoder drops frames to achieve a requested data rate that is too low to meet, even when compressing frames to the smallest possible size. But the encoder never drops a key frame (because a specific key frame rate or placement was requested). This leads to an impasse if too many key frames are requested with an insufficient data rate. If you encounter this situation, either increase your key frame interval, increase your requested data rate, or decrease your frame resolution to resolve the problem.
You cannot change a compressed file’s key frame interval without recompressing some or all of the file. You must set the key frame interval when you first compress it. If you need to change the key frame interval of a compressed file, recompress the file from the source file for best results.
CD-ROM padding is null data added to the end of a compressed video frame to adjust its size. Padding rounds the size of each frame up to the next highest multiple of 2 kilobytes. (It doesn't make every frame the same size. After padding, frames still vary in size, but all are an exact multiple of 2 kilobytes.) Originally, this setting supported CD-ROM drives with severe performance penalties when seeking any location that was not on a 2 kilobytes boundary. These drives are no longer commonly used, but the CD-ROM padding setting remains as a vestige of this problem.
Figure 2. Dialog without Quick Compress checked, Showing all options.
Quick compression trades faster encoding speed for lower image quality and less precise data rate control when you select the Data Rate option in your editing application. When using the Quality slider option, the quick compressor produces files that are larger in size.
The Quick Compress option is ideal for prototyping or previewing video edits, special effects, and other "pencil testing," but use the offline encoder in your final application to obtain the best image quality and compression, or to maintain a more consistent data rate.
Figure 3. The Indeo video 5 Dialog With the Quick Compressor Selected
Clips encoded with Scalability are flexible in two ways: frame quality and frame rate. Scalable clips can be played back with three distinct levels of frame quality (called High, Medium and Low). High quality is very similar to the quality of clips without scalability, but at a slightly higher data rate (by 10%). Video played at Medium quality is a little less sharp than High quality, but can be delivered with about 20 to 25% less data rate than High quality. Low quality is noticeably blurrier than High quality, but saves about 40-50% on data rate when compared to High quality.
Likewise, scalable clips can play back at up to four distinct levels of frame rate, depending on the frame rate of the source video. If you encode a video at 30 frames-per-second (fps), with a key frame interval of 30 frames, then frame rate scalability enables playback of that video at 30, 15, 5 and 1 fps, with corresponding reductions in the data rate required to transmit those video clips over a network. Both frame rate and frame quality scalability can be used at the same time, to give even more options for achieving a required data rate from a compressed Indeo video 5 file.
It's important to select Scalability in the Indeo video 5 Encoder Configuration dialog box if you want to enable progressive quality and frame rate for Progressive Downloading. To learn more about this capability, read the Indeo video 5 Progressive Download Publisher tool documentation.
Note: For best results using transparency, always provide the Indeo video 5 encoder with original RGB format video such as RGB24 or RGB32 video that was not captured in a chroma subsampled format such as YUV9, YUV12, M-JPEG or encoded in any other compressed format (including Indeo video). This allows the encoder to eliminate the "fringing" or "halo" effect that may otherwise appear around video sprites. Video that has ever been in a compressed or chroma-subsampled format has already been degraded so that the Indeo video 5 encoder can no longer prevent the fringing artifact. The encoder box offers three choices for handling transparency: first frame analysis, alpha channel, or none. Each is detailed below:
Note: Transparency is disabled when using quick compression.
To enable the Access Key:
This value is the code that an application or user must supply in order to play the video clip.
To enable local decode:
Specify the viewport size by selecting the appropriate size from the list box. The appropriate value is the one that is approximately the size of the smallest viewports your application will be using during playback. If your viewports are long and thin in either direction, then choose the viewport size setting that most closely matches the longest side of your smallest viewport.
To disable local decode:
Select "None" in the viewport size list box.
NOTE: Local Decode is disabled when using the quick compressor.
For example, suppose you'd like to extract a sequence in which the first frame is a delta frame. The application must decompress the first frame and recompress it as a key frame, using the previous key frame from the source file as a reference. All subsequent delta frames until the next key frame must also be decompressed and recompressed as new delta frames, using the newly-created key frame as a reference. But as soon as the next key frame is encountered, no further frames need to be recompressed, and applications that support limited recompression avoid doing so.
NOTE: Certain editing applications, like Adobe Premiere and Asymetrix's Digital Video Producer, do not have an explicit No Recompression option in the Compression dialog box. To avoid recompressing Indeo video source files, for example, select the same Indeo video codec when saving those files back to disk. The application compares the format of the compressed input files to the selected output format and automatically refrains from recompressing the data, or recompresses only when necessary.
Finally, it's a good idea to avoid joining files compressed in different formats into one clip. For example, if you join a file compressed using Indeo video with a file compressed using Microsoft's RLE* compressor, and select Indeo video as the save format, the RLE data must be decompressed and recompressed as Indeo video. Avoiding recompression is impossible under these circumstances.
Figure 4. Example Video File Without Transparency Frame
You must now create a frame that contains only the background color or range of colors that are to be rendered transparent, then paste it manually onto the beginning of the file. You can create the transparency frame in various ways; for example, by placing the video camera on a tripod, lighting your background as carefully as possible to produce the smallest possible range of colors, and shooting one frame of video. Another method that can be done after the video shoot is to export one of the actual video frames from your video file to an image editor, and erase all of the pixels that are not part of the background, replacing them with background colored pixels. After pasting in the transparency frame, your file appears as shown in Figure 5.
Figure 5. Example Video File With Transparency Frame
Ideally, the Indeo video 5 encoder would not return the transparency frame to the editing application. However, Video for Windows codecs are required to return one compressed frame for every source frame they are given. So even though you don't want the compressed file to play the transparency frame first, the Indeo video 5 encoder must return it.
Editing software enhanced to support the Indeo video 5 codec ignores the transparency frame, and does not write it to the output file. An editor that is not enhanced to support the Indeo video 5 codec may pair the transparency frame with the first frame of the audio, and write the audio and video data as an .AVI frame. After this initial mispairing, the first frame of video is paired with the second frame of audio, the second frame of video with the third frame of audio, and so on. The resulting file has 101 frames of video but only one hundred frames of audio. The audio and video are out of sync by one frame.
In most video-editing software, this problem can be avoided by ensuring that the beginning of the audio is aligned with the second frame of video (the first frame after the transparency frame). In any case, if your editing application does not know about Indeo video 5 transparency, you will want to remove the first frame of the video.
To use First frame Analysis:
The codec always returns the transparency frame as a key frame, and the actual first frame of video is also a key frame. After you delete the transparency frame, the file still starts with a key frame and can be saved without causing recompression.
* Legal Information © 1998 Intel Corporation